import { EntitySchema } from '@mikro-orm/core';

export class LeGoodsData {
  id!: string;
  goodsId!: string;
  paramValue!: string;
  price!: string;
  stocks: number = 0;
  costPrice?: string;
  weight?: string;
  goodsSn?: string;
  isDeleted?: boolean;
  createdTime?: string;
  updatedTime?: string;
  deletedTime?: string;
  taskStock: number = 0;
  taskNumber!: string;
  taskPrice?: string;
  taskLimit?: string;
  taskStatus: boolean = false;
}

export const LeGoodsDataSchema = new EntitySchema({
  class: LeGoodsData,
  properties: {
    id: { primary: true, type: 'string', columnType: 'bigint' },
    goodsId: { type: 'string', columnType: 'bigint', defaultRaw: `100`, index: '商品id' },
    paramValue: { type: 'string', length: 255, default: '1' },
    price: { type: 'string', columnType: 'numeric(10,2)' },
    stocks: { type: 'number', default: 0 },
    costPrice: {
      type: 'string',
      columnType: 'numeric(10,2)',
      nullable: true,
      defaultRaw: `0.00`,
    },
    weight: {
      type: 'string',
      columnType: 'numeric(6,2)',
      nullable: true,
      defaultRaw: `0.00`,
    },
    goodsSn: { type: 'string', length: 50, nullable: true },
    isDeleted: { type: 'boolean', nullable: true },
    createdTime: { type: 'string', columnType: 'bigint', nullable: true },
    updatedTime: { type: 'string', columnType: 'bigint', nullable: true },
    deletedTime: { type: 'string', columnType: 'bigint', nullable: true },
    taskStock: { type: 'number', default: 0 },
    taskNumber: { type: 'string', columnType: 'bigint', defaultRaw: `1` },
    taskPrice: {
      type: 'string',
      columnType: 'numeric(10,2)',
      nullable: true,
      defaultRaw: `0.00`,
    },
    taskLimit: { type: 'string', columnType: 'bigint', nullable: true },
    taskStatus: { type: 'boolean', default: false },
  },
});
